[MSCRIPTING-7] binding the session and servers helper in binding context - #4
[MSCRIPTING-7] binding the session and servers helper in binding context#4rmannibucau wants to merge 1 commit into
Conversation
| bindings.put( "session", session ); | ||
| bindings.put( "project", project ); | ||
| bindings.put( "log", getLog() ); | ||
| bindings.put( "servers", new Servers( session, settingsDecrypter ) ); |
There was a problem hiding this comment.
I have doubts about this one, servers has never been used as a variable. Better to stick to settings with resolved values.
There was a problem hiding this comment.
Do we have it already? I would like to avoid to decipher the whole settings each time (this is done only when needed) because it can slow down the execution a loooot for nothing in practise.
Happy to wrap it in a MavenScripting wrapper which would expose this kind of API (so script would use mavenScripting.servers.find(...))
There was a problem hiding this comment.
If I understand what you need and staying close to what Maven offers, I think you should focus on session.getRepositorySession().getAuthenticationSelector().getAuthentication(RemoteRepository)
There was a problem hiding this comment.
What I want is a Server#password in clear but I don't want to decipher all servers upfront. From what I saw, getSettings() is NOT clear there so I would have to "clearify" it before binding it which I want to avoid so I thought using a lazy simple accessor is more script friendly than exposing the session and letting user use plexus container to do lookups to decipher values.
|
I'm going to close this one as I consider this a security vulnerabilty. The introduction of |
|
@rfscholte will you also prevent using any mojo? It is the same security level. Without that this plugin is not that helping in most cases IMHO (no easy website custo/generation), no CI/CD etc... |
|
You could also add: from #7 if you think it adds any benefits. |
|
@bmarwell this is true but this is also something the script somehow know in the context of a project. What would be more useful is a replacement for plexus container to lookup any potentially needed bean or a loose coupling like in exec:java (constructor injection runnable case) but my suspicion is maven (4) misses a container handler for these cases. |
|
Re-opened for new evaluation |
|
A big -1 here |
|
@cstamas any rational behind and proposal to solve the related issue (enable to do proper resolutions from the script)? |
|
This is a matter of principle, and IMHO, vision. Plugins like these are like "swiss knives" and allows hacking, in effect, like Ant or other tools allow it (and makes Maven hackable just like one would do with Ant). Maven IMHO should be more like "set of Un*x tools" instead: set of battle tested (but also simple) plugins, that do few things, but do them well. If someone is akin for "swiss knife" plugins like these, for me is clear sign that they want to even widen their "hacking", that is IMHO another sign, they should be using Gradle, Ant or whatever else. Maven is a declarative build system. And I did not even mention the reasons Robert brought up.... (plus multitude of other reasons). |
This is also already possible in the exec plugin, and no one said this was a vuln (see Romains comment). Then, this would mean you need also get rid of exec-plugin. Then, what about the requirements history? Why was this plugin released in the first place? There could have been a vote against it at that time? |
|
It is not all black or white of course. We do need some "backdoors" open, for case of "emergency", if no plugin exists that does what you need. But if you google it, you will see the trend: "use hack in maven, but if you need it too often, write a plugin for it" tendency. And we must not lose this. This is why originally writing maven plugins was possible using ant scripts and beanshell as well. Beanshell, Ant script, they were all there to lower the plugin authoring barrier, BUT, those were plugins, they used plugin API, had descriptors, etc, so any future thing like build avoidance, incremental build (real one, not what we have today), etc. could rely on them. Problem is when "hacks" remain hacks, or worse, when "hacks become pattern" (of using some "special" (backdoor) plugin). So if you have ant/exec plugin in build, it is okay, as long as you do not stick with it. But in our case, I see pattern of building some "library of hacks" on top of these, that makes ANY of these "solutions" non reusable, non shared, not maven plugins If you need something special, hack it once. But second time write a plugin for it. Period. In short, we do need "stepping stone" plugins (hacks, like exec, ant plugins) to solve some ad-hoc scenarios, BUT these are stepping stones, in a sense, if pattern is repeated, they should be made into reusable plugins ultimately, while I see no intention of that happening here. In contrary, I see quite the opposite intent. |
|
@cstamas I'm on the camp to enable people to do what works for them, for me maven key is dependencies and it must stay static, rest (build pipeline) already broke maven original design and convention and it is bad to need to create a module/project for a build need so I'm clearly keen to see this kind of thing happening. No strong push from me there since I moved to exec and some companions but think it is sane. |
|
I'm somewhere between the lines here. If you have a common use case, a dedicated plugin is probably a better solution compared to the exec-, antrun-, or scripting-plugin. I'll say let's skip this pr for now... There's also #7 FWIW. |
| private MavenProject project; | ||
|
|
||
| // script variables | ||
| @Parameter(defaultValue = "${session}", readonly = true) |
There was a problem hiding this comment.
Is there a pro? I tend to prefer to limit the API (#imports) but if there is some advantage i'll do
|
Resolve #44 |
|
There are some pretty heavy -1's on this, and no approvals so I'm going to close this one as rejected. |
|
Tempted to say it should be reopened or another fix be proposed cause as of today the scripting plugin stays hard to use without that making exec superseeding scripting plugin. For security point: it is mainly convenience since everything is available while the eval impl doesn't fork. FTR exec plugin supports it out of the box but requires to compile something before which isnot as neat as scripting plugin (a module/project or the main module if the build classes are excluded in jar plugin): https://github.com/mojohaus/exec-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/exec/AbstractExecJavaBase.java#L518. |
|
Lets keep it open for future. Maybe we will have more voiced or something will change in mean time. |
|
Hi guys, can you review it again? |
|
Tests are failing. Fixing that would be required for review. I don't have a particular opinion on this, but I note that other people whose opinion I respect are all negative about this, so I don't hold out high hopes here. It's uncommon for a PR to get multiple informed -1 votes so it's probably worth paying attention to. |
430872f to
abd7db1
Compare
abd7db1 to
9dab711
Compare
|
Ok so build should be green now :) @cstamas while I agree on your phrasing I also met too often these cases (a lot around living doc and living deployments, rarely on the build phase itself - the side note there is it is often specific to the infra/project) to be happy with "write a plugin" in current form today and we'll not solve plugin entry cost until at least maven 6 I think so can you revise your -1 to at least a +0? |
| import org.apache.maven.settings.crypto.SettingsDecryptionResult; | ||
| import org.codehaus.plexus.PlexusContainerException; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; |
There was a problem hiding this comment.
why are we using org.sonatype instead of org.codehaus.plexus?
|
Hi there! I’ve been following this PR and I think exposing the MavenSession instance is a crucial addition for this plugin. It would significantly increase the scripts' capabilities by allowing access to project properties, settings, and the reactor state in a straightforward way. I personally prefer this plugin over others like gmavenplus due to its simplicity and 'Maven-native' feel. Is there anything I can help with to move this forward? It would be great to see this merged and released. Thanks for the effort! |
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MSCRIPTING-XXX] - Fixes bug in ApproximateQuantiles,where you replace
MSCRIPTING-XXXwith the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verifyto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.